/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * install1.java
 *
 * Created on 04-ene-2012, 11:15:18
 */
package instalacion;

import idiomas.messages;
import java.io.File;
import java.sql.SQLException;
import java.util.Locale;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFileChooser;

/**
 *
 * @author Cristian
 */
public class install1 extends javax.swing.JFrame {
    String ruta;
    /** Creates new form install1 */
    public install1() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        logo1 = new javax.swing.JLabel();
        barra = new javax.swing.JProgressBar();
        jComboBox1 = new javax.swing.JComboBox();
        jButton1 = new javax.swing.JButton();
        lenguageSelect = new javax.swing.JComboBox();
        lenguageLabel = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        mensajes = new javax.swing.JTextArea();
        jButton2 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setBackground(new java.awt.Color(255, 255, 255));

        jLabel1.setText("Seleccione la instalacion:");

        logo1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/instalacion/master.PNG"))); // NOI18N

        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Usuario(basica)", "Mantenimiento", "Supervisor(completa)" }));
        jComboBox1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox1ActionPerformed(evt);
            }
        });

        jButton1.setText("Instalar");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        lenguageSelect.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Español", "English" }));
        lenguageSelect.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                lenguageSelectActionPerformed(evt);
            }
        });

        lenguageLabel.setText("Idioma:");

        mensajes.setColumns(20);
        mensajes.setEditable(false);
        mensajes.setLineWrap(true);
        mensajes.setRows(5);
        mensajes.setText("Bienvenido al asistente de instalacion.\nLe agradecemos haber elegido nuestro programa de gestion de incidencias.\nLos pasos a seguir son:\n\t1.- Seleccione el idioma.\n\t2.- Seleccione el tipo de instalacion.\n\t3.- Selecciona la ruta.\n\t4.- Pulse el boton de Instalar.\n\t");
        mensajes.setWrapStyleWord(true);
        jScrollPane2.setViewportView(mensajes);

        jButton2.setText("Seleccionar Ruta");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(logo1, javax.swing.GroupLayout.DEFAULT_SIZE, 527, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jComboBox1, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(lenguageLabel)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(lenguageSelect, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, 136, Short.MAX_VALUE)
                            .addComponent(jLabel1)
                            .addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(barra, javax.swing.GroupLayout.PREFERRED_SIZE, 353, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(28, 28, 28))
                            .addComponent(jScrollPane2))))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lenguageLabel)
                            .addComponent(lenguageSelect, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 24, Short.MAX_VALUE)
                        .addComponent(jButton2)
                        .addGap(18, 18, 18)
                        .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 198, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(barra, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(18, 18, 18)
                .addComponent(logo1, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void lenguageSelectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_lenguageSelectActionPerformed
        barra.setValue(10);
        String Idioma = (String) lenguageSelect.getSelectedItem();         
        switch (lenguageSelect.getSelectedIndex()) {             
            case 0: //Español                 
                Idioma = "ES";                 
                break;             
            case 1: //Ingles                 
                Idioma = "EN";                 
                break;         
        }         
        Locale locale = new Locale(Idioma);         
        messages.setLocale(locale);
        jButton2.setText(messages.getString("SelectRuta"));
        jButton1.setText(messages.getString("Instalar"));
        lenguageLabel.setText(messages.getString("Language"));
        jLabel1.setText(messages.getString("EtiqInstall"));
        mensajes.setText(messages.getString("mensajeInstall"));
        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] 
                { 
                    messages.getString("installOption1"), 
                    messages.getString("installOption2"), 
                    messages.getString("installOption3") 
                }));
    }
        // TODO add your handling code here:         String Idioma = (String) lenguageSelect.getSelectedItem();         switch (lenguageSelect.getSelectedIndex()) {             case 0: //Español                 Idioma = "ES";                 break;             case 1: //Ingles                 Idioma = "EN";                 break;         }         Locale locale = new Locale(Idioma);         messages.setLocale(locale);         lenguageLabel.setText(messages.getString("Language"));         LimpiarButton.setText(messages.getString("Clear"));         EnviarButton.setText(messages.getString("Send"));         HistorialButton.setText(messages.getString("Record"));         Descripcion.setText(messages.getString("InsertYourDescription"));     }//GEN-LAST:event_lenguageSelectActionPerformed

        private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox1ActionPerformed
        // TODO add your handling code here:
            barra.setValue(20);
    }//GEN-LAST:event_jComboBox1ActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        barra.setValue(100);
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:
            // TODO add your handling code here:
        barra.setValue(40);
            final JFileChooser fc = new JFileChooser();
            //fc.setFileSelectionMode( JFileChooser.DIRECTORIES_ONLY);// para carpetas
            int returnVal = fc.showSaveDialog(this);
            if (returnVal == JFileChooser.APPROVE_OPTION) {//nos aseguramos q haya selecionado algun archivo
                File dir = fc.getSelectedFile();
                ruta=dir.toString();
                //System.out.println(ruta);
            }
    }//GEN-LAST:event_jButton2ActionPerformed
        
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(install1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(install1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(install1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(install1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new install1().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JProgressBar barra;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JLabel lenguageLabel;
    private javax.swing.JComboBox lenguageSelect;
    private javax.swing.JLabel logo1;
    private javax.swing.JTextArea mensajes;
    // End of variables declaration//GEN-END:variables
}
